/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Mod8_Ex2;

/**
 *
 * @author Root
 */
public class Account {

    protected double balance;

    public Account() {
    }

    public Account(double  balance) {
        this.balance = balance;

    }

    public double getBalance() {
        return balance;

    }

    public void  Deposit(double amt) throws OverDraftException {
        if (amt < 0) {
            System.out.println("ko dc");
        } else {
            balance+=amt;
        }

    }

    public void withdraw(double amt) throws OverDraftException {
        if (amt > balance) {
            throw new  OverDraftException("ko thuc hien dc",amt-balance);
//            return 0;


        } else {

            
             balance-=amt;
        }

    }

    @Override
    public String toString() {
        return "has a balance of " + balance;
    }

}
